package com.fanqwz.kotlinmvvm.common.util.log

import org.slf4j.Logger
import org.slf4j.LoggerFactory

/**
 * Created by fanqwz on 2017/10/27.
 */

class MyLogger(var logger : Logger) {

    fun logd(message: String) {
        logger.debug(message)
    }

    fun loge(message: String, error: Throwable? = null) {
        logger.error(message, error)
    }

    fun trace(message: String) {
        logger.trace(message)
    }

}

fun getLogger(clazz: Class<out Any>): MyLogger {
    return MyLogger(LoggerFactory.getLogger(clazz.simpleName))
}


inline fun Any.logd(message: String) {
    LoggerFactory.getLogger(this::class.simpleName ?: "").debug(message)
}
inline fun Any.loge(message: String, throwable: Throwable? = null) {
    LoggerFactory.getLogger(this::class.simpleName?: "").error(message, throwable)
}
